#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright: (c)  : @Time 2025/3/29 08  @Author  : hjl
# @Site    : 
# @File    : comm.py
# @Project: alibaba_spider
# @Software: PyCharm
# @Desc    :
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from functools import wraps


def Retry(second):
    def decorator(func):
        @wraps(func)
        def warpper(*args, **kwargs):
            att = 0  # 计数器
            while att < second:  # 按照计数器条件来循环
                try:
                    return func(*args, **kwargs)
                except Exception as e:
                    att += 1  # 计数器累加

        return warpper

    return decorator
